<?php /*a:2:{s:63:"/www/wwwroot/pay.rym.best/application/user/view/index/main.html";i:1563242586;s:66:"/www/wwwroot/pay.rym.best/application/user/view/common/head_s.html";i:1563242578;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title><?php echo htmlentities($title); ?>-<?php echo htmlentities($sys['name']); ?><?php echo htmlentities($userInfo['voice']); ?></title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="keywords" content="<?php echo htmlentities($sys['key']); ?>">
    <meta name="description" content="<?php echo htmlentities($sys['des']); ?>">
    <link rel="shortcut icon" href="/favicon.ico"/>  
    <link rel="stylesheet" href="/static/plugins/layui/css/layui.css">
    <link rel="stylesheet" href="/static/user/css/main.css">
    <link rel="stylesheet" href="/static/common/css/font.css" media="all">
</head>
<script src="/static/plugins/layui/layui.js"></script> 
<script src='https://cdn.bootcss.com/socket.io/2.0.3/socket.io.js'></script>  
<script type="text/javascript">
function playv(){
    //消息提示音
    var audio = document.createElement("audio");
    if (audio.canPlayType("audio/mp3")) {
        audio.src = "/static/default.mp3";
    }else if(audio.canPlayType("audio/ogg")) {
        audio.src = "/static/default.ogg";
    } 
    audio.play();//消息提示音 END    
}
// 订单消息同步通知
layui.use(['layer','jquery'], function() {
    var layer = layui.layer,$ = layui.jquery;
    var socket = io('http://'+document.domain+':2120');   // 连接服务端
    socket.on('new_msg', function(msg){ // 后端推送来消息时            
        arr=msg.split("|");
        var m_userid=arr[0];
        var m_agentid=arr[1];
        var userid="<?php echo htmlentities($userInfo['id']); ?>"; 
        var voice="<?php echo htmlentities($userInfo['voice']); ?>"; 
        if(m_userid!='0' && m_userid==userid){                
            layer.msg("您有新订单提醒",{time:2000,icon:1},function(){   
                window.frames['main_pan'].location.href = "<?php echo url('user/order/index'); ?>";     
            });  
            if(voice=='open'){
                playv();
            }           
        }
        if(m_agentid!='0' && m_agentid==userid){             
            layer.msg("您有新的代理订单提醒",{time:2000,icon:1},function(){  
                window.frames['main_pan'].location.href = "<?php echo url('user/agent/orderlist'); ?>";   
            });   
            if(voice=='open'){
                playv();
            }  
        } 
    }); 
}); 
</script>
  
<div class="main">
    <div class="userinfo">
        <div class="avatar"><img src="/static/user/images/avatar.jpg" alt="<?php echo htmlentities($userInfo['username']); ?>"></div>
        <div class="infos">
            <div class="pull-left"> 
                <?php if($userInfo['state']===0): ?>
                <li><a class="layui-btn layui-btn-xs" id="trade" data-type="reload"><i class="layui-icon layui-anim layui-anim-rotate layui-anim-loop">&#xe63d;</i> 交易中，点击停止交易</a></li> 
                <?php else: ?>
                <li><a class="layui-btn layui-btn-danger layui-btn-xs" id="trade" data-type="reload"><i class="layui-icon">&#xe63d;</i> 停止交易，点击启动交易</a></li>
                <?php endif; if($userInfo['voice']=='open'): ?>
                <li><a class="layui-btn layui-btn-xs" id="voice" data-type="reload"><i class="layui-icon">&#xe645;</i> 提示音开启，点击关闭</a></li> 
                <?php else: ?>
                <li><a class="layui-btn layui-btn-danger layui-btn-xs" id="voice" data-type="reload"><i class="layui-icon">&#xe688;</i> 提示音关闭，点击开启</a></li>
                <?php endif; ?>
                <li><span class="value">姓名：</span><span class="name"><?php echo htmlentities($userInfo['username']); ?>(<?php echo htmlentities($userInfo['level_name']); ?>)</span></li>
                <li><span class="value">手机号：</span><span class="value"><?php echo htmlentities($userInfo['mobile']); ?></span></li>
                <li><span class="value">APPID：</span><span class="value"><?php echo htmlentities($userInfo['appid']); ?></span></li> 
                <li><span class="value">推荐上级：</span><span class="value"><?php echo htmlentities($agentname); ?></span></li> 
            </div>
            <div class="pull-right"><div class="banks"><a href="<?php echo url('user/financial/bank'); ?>" target="main_pan"><i class="icon icon-credit-card"></i>收款账号管理</a></div></div>
        </div> 
    </div> 
    <div class="home_pan">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-xs12 layui-col-sm4 layui-col-md4">
                <div class="layui-card">
                    <div class="layui-card-header"><i class="layui-icon">&#xe63c;</i>订单统计<em class="pull-right">单位：个</em></div>
                    <div class="layui-card-body">
                        <div class="layui-col-xs6"><span class="name">待处理</span><span class="value"><?php echo htmlentities($cdata['order_no']); ?></span></div> 
                        <div class="layui-col-xs6"><span class="name">全部订单</span><span class="value"><?php echo htmlentities($cdata['order_all']); ?></span></div>  
                    </div>
                </div>
            </div>
            <div class="layui-col-xs12 layui-col-sm4 layui-col-md4">
                <div class="layui-card">
                    <div class="layui-card-header"><i class="layui-icon">&#xe65e;</i>财务汇总<em class="pull-right">单位：元</em></div>
                    <div class="layui-card-body">
                        <div class="layui-col-xs6"><span class="name">累计收款</span><span class="value"><?php echo htmlentities($cdata['order_money']); ?></span></div>   
                        <div class="layui-col-xs6"><span class="name">支付手续费</span><span class="value"><?php echo htmlentities($cdata['order_money_pay']); ?></span></div> 
                    </div>
                </div>
            </div>
            <div class="layui-col-xs12 layui-col-sm4 layui-col-md4">
                <div class="layui-card">
                    <div class="layui-card-header"><i class="layui-icon">&#xe857;</i>通道统计<em class="pull-right">单位：个</em></div>
                    <div class="layui-card-body">
                        <div class="layui-col-xs6"><span class="name">激活的通道</span><span class="value"><?php echo htmlentities($cdata['channel_yes']); ?></span></div> 
                        <div class="layui-col-xs6"><span class="name">全部通道</span><span class="value"><?php echo htmlentities($cdata['channel_all']); ?></span></div>    
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-card-header">今日订单</div> 
    <!-- 未处理的订单 -->
    <div class="home_order"> 
        <table class="layui-table layui-hide" id="orderlist" lay-filter="listss"></table>
    </div>
    <!-- 未处理的订单 END-->
</div>
<script type="text/html" id="action">
    {{# if(d.state==0 && d.points==0){ }}
        <div class="layui-btn layui-btn-danger layui-btn-xs" lay-event="orderdel">删除</div>
    {{# }else{ }}
        <div class="layui-btn layui-btn-disabled layui-btn-xs">删除</div>
    {{# } }} 
</script>
<script type="text/html" id="payinfo"> 
    {{# if(d.bankid){ }}<div onmouseover="layer.tips('{{d.bank_name}}<br>收款账号：{{d.bank_no}}<br>支付时间：{{d.paytime}}',this,{area: 'auto',tips: [1, '#333']});" onmouseout="layer.closeAll();">{{d.payname}}</div>{{# } }} 
</script>
<script src="/static/plugins/layui/layui.js"></script>
<script>
    layui.use(['table','form'], function() {
        var table = layui.table,form = layui.form, $ = layui.jquery;
        var tableIn = table.render({
            id: 'listss',
            elem: '#orderlist',
            url: '<?php echo url("order/index"); ?>',
            method: 'post', 
            page: true,
            cols: [[ 
                {field: 'orderid', title: '平台订单号',align: 'center', width:138, fixed: true},
                {field: 'cionname', title: '币种名称',align: 'center', width: 120, fixed: true},
                {field: 'money', title: '订单金额',align: 'center', width: 120, fixed: true}, 
                {field: 'price', title: '单价/CNY',align: 'center', width: 100},
                {field: 'number', title: '数量',align: 'center', width: 100},
                {field: 'state_name', title: '订单状态',align: 'center', width: 100}, 
                {field: 'points_name', title: '上分状态',align: 'center', width: 100}, 
                {field: 'payname', title: '支付信息',align: 'center', width: 100,templet: '#payinfo'}, 
                {field: 'fei_user', title: '手续费',align: 'center', width: 90},  
                {field: 'channelname', title: '所属通道',align: 'center', width: 120}, 
                {field: 'shopname', title: '所属商户',align: 'center', width: 120}, 
                {field: 'orderid_out', title: '商户订单号',align: 'center', width: 150},  
                {field: 'note', title: '备注信息',align: 'center', width: 120},  
                {field: 'addtime', title: '提交时间',align: 'center', width: 142}, 
                {title: '操作', width: 80,align: 'center', fixed:'right',toolbar: '#action'},
            ]],
            limit: 10,
            where: {timequan:'today'}
        });  
        //搜索
        $('#trade').on('click', function () {  
            var userid="<?php echo htmlentities($userInfo['id']); ?>";
            var state="<?php echo htmlentities($userInfo['state']); ?>";
            $.post("<?php echo url('index/userstrade'); ?>",{userid:userid,state:state},function(res){
                if(res.status===1){
                    layer.msg(res.msg,{time:1000,icon:1},function(){ 
                        parent.location.reload();
                    });
                }else{
                    layer.msg(res.msg,{time:1000,icon:2});
                }
            });
        });
        $('#voice').on('click', function () {  
            var userid="<?php echo htmlentities($userInfo['id']); ?>";
            var voice="<?php echo htmlentities($userInfo['voice']); ?>";
            $.post("<?php echo url('index/usersvoice'); ?>",{userid:userid,voice:voice},function(res){
                if(res.status===1){
                    layer.msg(res.msg,{time:1000,icon:1},function(){ 
                        parent.location.reload();
                    });
                }else{
                    layer.msg(res.msg,{time:1000,icon:2});
                }
            });
        });
        table.on('tool(listss)', function(obj) {
            var data = obj.data;
            if(obj.event === 'orderdel') {
                layer.confirm('您确定要删除该订单吗？', function(index){ 
                    $.post("<?php echo url('order/del'); ?>",{id:data.id},function(res){
                        if(res.code===1){
                            layer.msg(res.msg,{time:1000,icon:1});
                            tableIn.reload();
                        }else{
                            layer.msg(res.msg,{time:1000,icon:2});
                        }
                    });
                    layer.close(index);
                });
            }
            if(obj.event === 'checkpay') {
                layer.confirm('请确定您是否已经收到相应的款项！', function(index){ 
                    $.post("<?php echo url('order/uppay'); ?>",{id:data.id},function(res){
                        if(res.code===1){
                            layer.msg(res.msg,{time:1000,icon:1},function(){ 
                                tableIn.reload();
                            });
                        }else{
                            layer.msg(res.msg,{time:1000,icon:2});
                        }
                    });
                    layer.close(index);
                });
            }
            if(obj.event === 'shangfeng') {  
                layer.open({
                    type: 1 
                    ,id: 'shangfeng' //防止重复弹出
                    ,title: '您正在进行上分操作！'
                    ,btn: ['自动上分','手动上分']
                    ,btnAlign: 'c' //按钮居中
                    ,shade: 0.7 //不显示遮罩
                    ,yes: function(){
                        $.post("<?php echo url('pay/notify/index'); ?>",{id:data.id},function(res){
                            console.log(res);
                            if(res.code===1){
                                layer.msg(res.msg,{time:1000,icon:1},function(){ 
                                    tableIn.reload();
                                });
                            }else{
                                layer.msg(res.msg,{time:1000,icon:2});
                            }
                        });
                        layer.closeAll();
                    }
                    ,btn2:function(){
                        $.post("<?php echo url('order/gopoints'); ?>",{id:data.id,points:2},function(res){
                            if(res.code===1){
                                layer.msg(res.msg,{time:1000,icon:1},function(){ 
                                    tableIn.reload();
                                });
                            }else{
                                layer.msg(res.msg,{time:1000,icon:2});
                            }
                        });
                    } 
                });   
            }
        });  
    });  
</script>
</body>
</html>